/**
* Created by wl
* 项目管理>持有中-详情页-项目详情-项目详情编辑信息
*/
<template>
    <div class="ca-box ca-box-border-top-none ca-p-20">
        <div  v-if="!showEdit">
            <div class="ca-title">
                <h3>项目详情</h3>
                <el-button type="text" class="ca-edit-btn el-icon-edit ca-m-r-10 edit-btn" @click="editInfo" :disabled="!isAuthIndexSee">编辑</el-button>
            </div>
            <el-form label-width="180px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="公司名称：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{itemHoldInfoEntity.companyName}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="社会信用统一代码：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{itemHoldInfoEntity.creditCode}}
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="公司成立时间：" class="el-form-item-m-b-0 el-form-item__content-font-12">
                            {{itemHoldInfoEntity.registrationTime}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="企业性质：" class="el-form-item-m-b-0 el-form-item__content-font-12">
                            {{itemHoldInfoEntity.companyNature | getNameById('nature')}}
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="法人代表：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{itemHoldInfoEntity.representative}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="注册资本（万元）：" class="el-form-item-m-b-0 el-form-item__content-font-12">
                            <span>{{itemHoldInfoEntity.registeredCapital | format1 }}</span>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="注册地址：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{registrationDetailed1}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="办公地址：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{registrationDetailed2}}
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="项目轮次：" class="el-form-item-m-b-0 el-form-item__content-font-12">
                            {{itemHoldInfoEntity.prostatus | getNameById('prostatus')}}
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="证券代码：" class="el-form-item-m-b-0 el-form-item__content-font-12 el-break">
                            {{itemHoldInfoEntity.securitiesCode}}
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <csProjectDetails v-else :showBtn="true" :id="itemHoldInfoEntity.id" :itemId="itemHoldInfoEntity.itemId" @close="close" @save='save'></csProjectDetails>
    </div>
</template>
<script type="text/ecmascript-6">
    import {api} from '../../api';
    import {STATUS_HTTP_SUCCESS, apiHttp} from '__service/csHttp';
    import { addRemind, isNoAuth } from '__service/utils';
    export default {
        data() {
            return {
                isAuthIndexSee: isNoAuth('持有中项目-项目详情-编辑'),
                registrationDetailed1: '', //注册地
                registrationDetailed2: '', //办公地
                showEdit: false,
                itemHoldInfoEntity: {
                    businessLicence: '', //营业执照
                    companyName: '', //公司名称
                    companyNature: '', //企业性质
                    creditCode: '', //社会信用统一代码
                    id: '', //id
                    itemId: '', //项目id
                    // officeAddress: '', //办公地址
                    prostatus: '', //轮次
                    // registeredAddress: '', //注册地址
                    registeredCapital: 0, //注册资本
                    registrationTime: '', //注册时间
                    representative: '', //公司法人代表
                    securitiesCode: '', //证券代码
                },
                region: [], //注册地和办公地
            }
        },
        watch: {
        },
        props: {},
        mounted() {
            this.getInfo();
        },
        methods: {
            close() {
                this.showEdit = false
                this.getInfo()
            },
            async save() {
                this.showEdit = false
                await this.getInfo();
                // 添加小红点
                await addRemind({
                    dataId: this.$route.params.itemId, // 业务id
                    dataTab: 0, // tab页顺序 head 也为0 新建为'-1'
                    dataType: 2, // 1拟投资项目,2已投资项目,3母基金,4拟设立基金,5已设立基金,6客户,7潜在项目
                });
                // 根据第三方组件来调用 父组件中定义的方法 重新获取小红点
                this.$root.Dot.$emit('getDotList');
                // 添加小红点 end
            },
            editInfo() {
                this.showEdit = true
            },
            getInfo() {
                let that = this
                apiHttp(api.CHECK_INVESTED, {itemId: this.$route.params.itemId}).then(ret => {
                    if (ret.resCode === STATUS_HTTP_SUCCESS) {
                        that.itemHoldInfoEntity = ret.data.itemHoldInfoEntity
                        that.region = ret.data.region
                        if (that.itemHoldInfoEntity.registrationTime === null) {
                            that.itemHoldInfoEntity.registrationTime = ''
                        } else {
                            that.itemHoldInfoEntity.registrationTime = that.$moment( that.itemHoldInfoEntity.registrationTime ).format('YYYY-MM-DD');
                        }
                        // 处理地区
                        that.registrationDetailed1 = ''
                        that.registrationDetailed2 = ''
                        if (that.region && that.region.length !== 0) {
                            that.region.map(item => {
                                if (item.businessType === 1) {
                                    that.registrationDetailed1 = item.registrationDetailed
                                } else if (item.businessType === 2) {
                                    that.registrationDetailed2 = item.registrationDetailed
                                }
                            })
                        }
                    }
                })
            },
        },
        components: {
            csProjectDetails: require('./edit'),
        },
    }
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.edit-btn {
    float: right;
    cursor: pointer;
}
.el-break {
    word-wrap:break-word;
}
</style>
